package com.bedpotato.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class CreateServerThread extends Thread {
	private Socket client;
	private BufferedReader in;
	private PrintWriter out;

	public CreateServerThread(Socket s) throws IOException {
		client = s;
		in = new BufferedReader(new InputStreamReader(client.getInputStream(),
				"GB2312"));
		out = new PrintWriter(client.getOutputStream(), true);
		out.println("--- Welcome ---");
		start();
	}

	public void run() {
		try {
			String line = in.readLine();
			while (!line.equals("bye")) {
				String msg = createMessage(line);
				out.println(msg);
				line = in.readLine();
			}
			out.println("--- See you, bye! ---");
			client.close();
		} catch (IOException e) {
		}
	}

	private String createMessage(String line) {
		return "123";

	}

}
